package com.blacktea.structuralpatterns.bridgepattern.client;

import cn.hutool.core.codec.Base64;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

/**
 * @description: QQ 客户端
 * @author: black tea
 * @date: 2023/3/22 15:40
 */
@Slf4j
@Component
public class QQClient implements Client {

    @Override
    public void login() {
        log.info("QQ客户端进行QQ登录授权。");
    }

    @Override
    public void sendMsg(String message) {
        // // 模仿加密，实际根据文档修改
        String encryptMsg = Base64.encode(message, StandardCharsets.UTF_8);
        log.info("QQ客户端发送编码后的消息，消息内容：【{}】", encryptMsg);
    }

    @Override
    public String receiveMsg(String message) {
        //  // 模仿解密，实际根据文档修改
        String decryptMsg = Base64.decodeStr(message, StandardCharsets.UTF_8);
        log.info("QQ客户端接收消息并解码之后，消息内容：【{}】", decryptMsg);
        return decryptMsg;
    }
}
